package com.gitee.wsl.mathematics.matrix.ext

import com.gitee.wsl.mathematics.matrix.Matrix
import kotlin.math.min


/**
 * Get the main diagonal of a [ZeroMatrix]
 * 获取 [ZeroMatrix] 主对角线
 */
//val ZeroMatrix.diagonal get() = List(min(row, column)) { .0 }
/**
 * Get the main diagonal of a [NumberMatrix]
 * 获取 [NumberMatrix] 主对角线
 */
//val NumberMatrix.diagonal get() = List(dim) { value }
/**
 * Get the main diagonal of an unspecific [ZeroMatrix]
 * 获取非特定 [Matrix] 主对角线
 */
val <T:Number> Matrix<T, *, *>.diagonal get() = (0..min(rowCount, colCount)).map { get(it, it) }